package com.rp.data.data_mqtt;

import com.alibaba.fastjson.JSON;
import com.rp.common.result.ResultDTO;
import com.rp.mqtt.IMqttSender;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * 类说明:
 *
 * @author ****
 * @date 2021-04-15 15:30  新建
 */
@Api(tags = "操作")
@RestController
@Slf4j
@RequestMapping("/mqtt")
public class MqttController {




    @Autowired
    private IMqttSender iMqttSender;

//    @ApiOperation(value = "获取配置文件")
//    @GetMapping(value = "/getRuffJsonModel")
//    public ResultDTO<List<RuffJsonModel>> getRuffJsonModel(@RequestParam @ApiParam(value = "网关SN",required = true) String sn,
//                                                           @RequestParam(required = false) @ApiParam(value = "读写") String rw) {
//        List<RuffJsonModel> models = collectorFcService.getRuffJsonModels(sn, rw);
//        System.out.println(models);
//        return ResultDTO.success().data(models);
//    }


    @ApiOperation(value = "推送数据")
    @GetMapping(value = "/pushData")
    @Transactional
    public ResultDTO pushData(@RequestParam @ApiParam(value = "采集设备ID", required = true) String collectorId,
                              @RequestParam @ApiParam(value = "采集设备对应方法库ID", required = true) String collectorTypeFcId,
                              @RequestParam @ApiParam(value = "控制状态", required = true) Integer state) {

        return ResultDTO.bad().message("找不到对应设备");
    }
    @ApiOperation(value = "重启网关")
    @GetMapping(value = "/reStart")
    public ResultDTO reStart(@RequestParam @ApiParam(value = "网关SN",required = true) String sn) {
        iMqttSender.sendToMqtt("", 0, "");
            return ResultDTO.success();
        }


}
